<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!-- Copyright 1997 The Open Group, All Rights Reserved -->
<title>inet_addr</title>
</head><body bgcolor=white>
<center>
<font size=2>
The Single UNIX &reg; Specification, Version 2<br>
Copyright &copy; 1997 The Open Group

</font></center><hr size=2 noshade>
<h4>NAME</h4><blockquote>
inet_addr, inet_network, inet_makeaddr, inet_lnaof, inet_netof, inet_ntoa - Internet address manipulation
</blockquote><h4>SYNOPSIS</h4><blockquote>
<pre><code>

#include &lt;<a href="arpainet.h.html">arpa/inet.h</a>&gt;

in_addr_t inet_addr(const char *<I>cp</I>);

in_addr_t inet_lnaof(struct in_addr <I>in</I>);

struct in_addr inet_makeaddr(in_addr_t <I>net</I>, in_addr_t <I>lna</I>);

in_addr_t inet_netof(struct in_addr <I>in</I>);

in_addr_t inet_network(const char *<I>cp</I>);

char *inet_ntoa(struct in_addr <I>in</I>);
</code>
</pre>
</blockquote><h4>DESCRIPTION</h4><blockquote>
The
<i>inet_addr()</i>
function converts the string pointed to by <I>cp</I>, in the Internet standard
dot notation, to an integer value suitable for use as an Internet address.
<p>
The
<i>inet_lnaof()</i>
function takes an Internet host address specified by <I>in</I> and extracts the
local network address part, in host byte order.
<p>
The
<i>inet_makeaddr()</i>
function takes the Internet network number specified by <I>net</I> and the
local network address specified by <I>lna</I>, both in host byte order, and
constructs an Internet address from them.
<p>
The
<i>inet_netof()</i>
function takes an Internet host address specified by <I>in</I> and extracts the
network number part, in host byte order.
<p>
The
<i>inet_network()</i>
function converts the string pointed to by <I>cp</I>, in the Internet standard
dot notation, to an integer value suitable for use as an Internet network
number.
<p>
The
<i>inet_ntoa()</i>
function converts the Internet host address specified by <I>in</I> to a string
in the Internet standard dot notation.
<p>
All Internet addresses are returned in network order (bytes ordered from left
to right).
<p>
Values specified using dot notation take one of the following forms:
<dl compact>

<dt>a.b.c.d<dd>When four parts are specified, each is interpreted as a byte of data
and assigned, from left to right, to the four bytes of an Internet address.

<dt>a.b.c<dd>When a three-part address is specified, the last part is interpreted as
a 16-bit quantity and placed in the rightmost two bytes of the network address.
This makes the three-part address format convenient for
specifying Class B network addresses as 128.<I>net</I>.<I>host</I>.

<dt>a.b<dd>When a two-part address is supplied, the last part is interpreted as a
24-bit quantity and placed in the rightmost three bytes of the network address.
This makes the two-part address format convenient for
specifying Class A network addresses as <I>net</I>.<I>host</I>.

<dt>a<dd>When only one part is given, the value is stored directly in the
network address without any byte rearrangement.

</dl>
<p>
All numbers supplied as parts in dot notation may be decimal, octal, or
hexadecimal, as specified in the ISO&nbsp;C standard (that is, a leading 0x or 0X
implies hexadecimal; otherwise, a leading 0 implies octal; otherwise, the
number is interpreted as decimal).
</blockquote><h4>RETURN VALUE</h4><blockquote>
Upon successful completion,
<i>inet_addr()</i>
returns the Internet address.
Otherwise, it returns (<B>in_addr_t</B>)(-1).
<p>
Upon successful completion,
<i>inet_network()</i>
returns the converted Internet network number.
Otherwise, it returns (<B>in_addr_t</B>)(-1).
<p>
The
<i>inet_makeaddr()</i>
function returns the constructed Internet address.
<p>
The
<i>inet_lnaof()</i>
function returns the local network address part.
<p>
The
<i>inet_netof()</i>
function returns the network number.
<p>
The
<i>inet_ntoa()</i>
function returns a pointer to the network address in Internet-standard dot
notation.
</blockquote><h4>ERRORS</h4><blockquote>
No errors are defined.
</blockquote><h4>APPLICATION USAGE</h4><blockquote>
The return value of
<i>inet_ntoa()</i>
may point to static data that may be overwritten by subsequent calls to
<i>inet_ntoa()</i>.
</blockquote><h4>SEE ALSO</h4><blockquote>
<i><a href="endhostent.html">endhostent()</a></i>,
<i><a href="endnetent.html">endnetent()</a></i>,
<i><a href="arpainet.h.html">&lt;arpa/inet.h&gt;</a></i>.
</blockquote><hr size=2 noshade>
<center><font size=2>
UNIX &reg; is a registered Trademark of The Open Group.<br>
Copyright &copy; 1997 The Open Group
<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]

</font></center><hr size=2 noshade>
</body></html>
